<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">开奖时间设置</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 彩票管理 <small> <i class="icon-double-angle-right"></i> 开奖时间设置 </small> </h1>
  </div>
  <div class="">
    <div class="tabbable">
      <ul class="nav nav-tabs" id="myTab">
        <foreach name="lottry_array" item="val" key="key">
        <if condition="$key neq 13 &&  $key neq 16 &&  $key neq 17 &&  $key neq 15 &&  $key neq 24">
          <li>
              <if condition="$key eq $c_id">
             <a class="btn btn-primary" href="{:U('Admin/Lottryodds/open_time',array('c_id'=>$key))}">{$val.text}</a>
              <else />
              <a class="btn btn-info" href="{:U('Admin/Lottryodds/open_time',array('c_id'=>$key))}">{$val.text}</a>
               </if>
          </li>
          </if> 
        </foreach>
	
		
      </ul>
      <div class="tab-content">
        <div class="table-responsive dataTables_wrapper"> 
          <!-- <include file="Layout/{$tpl}" />-->
          <form class="form-horizontal" action="{:U('Admin/Lottryodds/change_op_time')}" id="validation-form" method="post" enctype="multipart/form-data">
            <input type="hidden" value="{$c_id}" name="c_id">
            <table class="table table-bordered table-hover table-condensed">
              <tbody>
               <!-- <tr>
                  <td width="64">彩票类别</td>
                  <td>重庆时时彩<a href="#">【点击进入开奖设置】</a></td>
                </tr>-->
                <tr>
                  <td width="64"></td>
                  <td></td>
                </tr>
                <tr>
                  <td style="vertical-align:middle;">时间修改</td>
                  <td><div class="wan-spinner wan-spinner-1" style="vertical-align:middle;"><a href="javascript:void(0)" class="minus" onClick="javascript:OpeSeconds(1);">-</a>
                      <input id="seconds" name="seconds" value="60" maxlength="6" style="width:80px;" type="text">
                      <a href="javascript:void(0)" class="plus" onClick="javascript:OpeSeconds(2);">+</a></div>
                    <span style="display:inline-block; vertical-align:middle; padding-left:12px;">秒</span></td>
                </tr>
                <tr>
                  <td></td>
                  <td><button type="submit" class="btn btn-sm btn-info">确认修改</button></td>
                </tr>
              </tbody>
            </table>
            <table class="table table-center table-striped table-bordered table-hover dataTable">
              <thead>
                <tr>
                  <th>彩票期号</th>
                  <th>开盘时间</th>
                  <th>封盘时间</th>
                  <th>开奖时间</th>
                </tr>
              </thead>
              <tbody>
              <foreach name="data" item="v" key="k">
                <tr>
                  <td>{$v.periods}</td>
                  <td><input id="kaipan_{$v.periods}" name="kaipan[{$v.periods}]" value="{$v.kp_time}" maxlength="8" style="width:100px;" type="text"></td>
                  <td><input id="fengpan_{$v.periods}" name="fengpan[{$v.periods}]" value="{$v.fp_time}" maxlength="8" style="width:100px;" type="text"></td>
                  <td><input id="kaijiang_{$v.periods}" name="kaijiang[{$v.periods}]" value="{$v.kj_time}" maxlength="8" style="width:100px;" type="text"></td>
                </tr>
               </foreach>  
              </tbody>
            </table>
            <input id="nums" name="nums" value="{$count}" type="hidden">
            
          </form>
        </div>
        
        <!-- /.table-responsive --> 
      </div>
    </div>
  </div>
  <!-- /.table-responsive --> 
</div>
<div >{$page}</div>
</div>
</div>
<include file="Layout/js"/> 
<script src="__ADMIN_JS__/bootbox.js"></script>
<link rel="stylesheet" href="__ADMIN_JS__/wan-spinner/wan-spinner.css" />
  
<script type="text/javascript">
function OpeSeconds(type)
{
  var seconds = $("#seconds").val();
  var nums = $("#nums").val();
  
  switch (type)
  {
    case 1:
      for (var i = 1; i <= nums; i++)
      {
        //开盘-
        var oldkptime = $("#kaipan_" + i).val();
        var oldkpdate = new Date("2012/01/01 " + oldkptime);
        var newkptime = oldkpdate.getTime() - seconds * 1000;
        var newkpdate = new Date(newkptime);
        $("#kaipan_" + i).val(TimeFormat(newkpdate));
        
        //封盘-
        var oldfptime = $("#fengpan_" + i).val();
        var oldfpdate = new Date("2012/01/01 " + oldfptime);
        var newfptime = oldfpdate.getTime() - seconds * 1000;
        var newfpdate = new Date(newfptime);
        $("#fengpan_" + i).val(TimeFormat(newfpdate));
        
        //开奖-
        var oldkjtime = $("#kaijiang_" + i).val();
        var oldkjdate = new Date("2012/01/01 " + oldkjtime);
        var newkjtime = oldkjdate.getTime() - seconds * 1000;
        var newkjdate = new Date(newkjtime);
        $("#kaijiang_" + i).val(TimeFormat(newkjdate));
      }
      break;
    case 2:
      for (var i = 1; i <= nums; i++)
      {
        //开盘+
        var oldkptime = $("#kaipan_" + i).val();
        var oldkpdate = new Date("2012/01/01 " + oldkptime);
        var newkptime = oldkpdate.getTime() + seconds * 1000;
        var newkpdate = new Date(newkptime);
        $("#kaipan_" + i).val(TimeFormat(newkpdate));
        
        //封盘+
        var oldfptime = $("#fengpan_" + i).val();
        var oldfpdate = new Date("2012/01/01 " + oldfptime);
        var newfptime = oldfpdate.getTime() + seconds * 1000;
        var newfpdate = new Date(newfptime);
        $("#fengpan_" + i).val(TimeFormat(newfpdate));
        
        //开奖+
        var oldkjtime = $("#kaijiang_" + i).val();
        var oldkjdate = new Date("2012/01/01 " + oldkjtime);
        var newkjtime = oldkjdate.getTime() + seconds * 1000;
        var newkjdate = new Date(newkjtime);
        $("#kaijiang_" + i).val(TimeFormat(newkjdate));
      }
      break;
  }
}

function TimeFormat(datetime)
{
  var hours = datetime.getHours();
  hours = hours < 10 ? "0" + hours : hours;
  var minutes = datetime.getMinutes();
  minutes = minutes < 10 ? "0" + minutes : minutes;
  var seconds = datetime.getSeconds();
  seconds = seconds < 10 ? "0" + seconds : seconds;
  
  return hours + ":" + minutes + ":" + seconds;
}
</script>
</body>
</html>